/*===================== coord.c ======================*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "coord.h"


/* Create a new coord struct */
coord create_coord(const char* server, const int north, const int este){
	coord position = (coord) calloc(1, sizeof(struct _coord));

	position->server = (char*) calloc(strlen(server), sizeof(char));

	strcpy(position->server, server);
	position->north = north;
	position->este = este;

	return position;
}

/* delete a coord struct */
void delete_coord(coord *position){
   	free((*position)->server);
	free(*position);
	*position = NULL;
}

/* print to stdout a coord struct */
void print_coord(const coord position){

	if(position != NULL){
		if (position->server != NULL){
			printf("%s ", position->server);
			printf("%d:", position->north);
			printf("%d", position->este);
		}
			else
				printf("Erro: NULL coord member\n");
	}
	else
		printf("Erro: NULL coord\n");
}
